<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class GoodsImagesResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
//        dd($this);
//        return  parent::toArray($request);
        $data = parent::toArray($request);
        foreach ($data as $key=>$val){
            isset($val['img'])?$data[$key]['img'] = get_img_url($val['img']):"";
        }
//        return [
//            "img"=>isset($this->img)?get_img_url($this->img):"",
//        ];
        return $data;
    }
}
